<template>
	<view>

		<view v-if="shop_id!=6" class="flex">
			<view style="flex: 1;">
				<view class="card">
					<button open-type="contact" class="btn-window" style="line-height: 1.8;padding: 60rpx 20rpx;">
						<view class="flex" style="justify-content: space-around;">
							<view style="width: 100rpx;">
								<image src="/static/usercenter/weixin.png" mode="widthFix"
									style="width: 100rpx;height: 100rpx;"></image>
								<view><text>微信</text></view>
							</view>
						</view>
						<view class="u-text-center">
							<text style="font-size: 24rpx;color: #999999;">通过微信官方号联系</text>
						</view>
					</button>
				</view>
			</view>
			<view style="flex: 1;">
				<view class="card">
					<button @click="callCustomer" class="btn-window" style="line-height: 1.8;padding: 60rpx 20rpx;">
						<view class="flex" style="justify-content: space-around;">
							<view style="width: 100rpx;">
								<image src="/static/usercenter/dianhua.png" mode="widthFix"
									style="width: 100rpx;height: 100rpx;"></image>
								<view><text>电话</text></view>
							</view>
						</view>
						<view class="u-text-center">
							<text style="font-size: 24rpx;color: #999999;">时效快，推荐使用</text>
						</view>
					</button>
				</view>
			</view>
		</view>
		<view v-else>

			<view style="flex: 1;">
				<view class="card">
					<button @click="callCustomer" class="btn-window" style="line-height: 1.8;padding: 60rpx 20rpx;">
						<view class="flex" style="justify-content: space-around;">
							<view style="width: 100rpx;">
								<image src="/static/usercenter/dianhua.png" mode="widthFix"
									style="width: 100rpx;height: 100rpx;"></image>
								<view><text>电话</text></view>
							</view>
						</view>
						<view class="u-text-center">
							<text style="font-size: 24rpx;color: #999999;">时效快，推荐使用</text>
						</view>
					</button>
				</view>
				<view class="card">
					<button @longpress="saveImage" class="btn-window" style="line-height: 1.8;padding: 60rpx 20rpx;">
						<image mode="widthFix" src="https://www.cppsend.com/uploads/user/fuyi-custom.jpg"
							style="width: 100%;">
						</image>
					</button>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				shop_id: uni.getStorageSync('shopId'),
				service_phone: this.$store.state.goods.service_phone,
			};
		},
		mounted() {
			console.log(this.service_phone)

		},
		methods: {
			//拨打客服电话
			callCustomer() {
				let that = this;
				uni.showActionSheet({
					itemList: that.service_phone,
					success: function(res) {
						// console.log(res)
						uni.makePhoneCall({
							
							phoneNumber: that.service_phone[res.tapIndex] //仅为示例
						});
					},
					fail: function(res) {
						console.log(res.errMsg);
					}
				});
				// let that = this;

			},
			//保存二维码
			saveImage() {
				uni.downloadFile({
					url: 'https://www.cppsend.com/uploads/user/fuyi-custom.jpg',
					success: (res) => {
						uni.hideLoading();
						if (res.statusCode === 200) {
							uni.saveImageToPhotosAlbum({
								filePath: res.tempFilePath,
								success: function() {
									uni.showToast({
										title: "保存成功",
										icon: "none"
									});
								},
								fail: function() {
									uni.showToast({
										title: "保存失败，请稍后重试",
										icon: "none"
									});
								}
							});
						}
					},
					fail: (err) => {
						uni.showToast({
							title: "失败啦",
							icon: "none"
						});
					}
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.btn-window {
		background-color: #FFFFFF;
		border: none;
	}
</style>
